package day07.demo;

import java.util.Scanner;

public class CalTotalAvg02 {
    public static void main(String[] args) {
        double[] scores=inputDate(6);
        double avg=calAvg(scores);
        System.out.println("平均值为:"+avg);

    }
    public static double[] inputDate(int n){
        double[] scores=new double[n];
        Scanner sc=new Scanner(System.in);
        for (int i=0;i<scores.length;i++){
            System.out.println("请录入第"+(i+1)+"次平均分");
            scores[i]=sc.nextDouble();
        }
        return scores;
    }
    public static double calAvg(double[] scores){
        double total=0.0;//总分
        double max=scores[0];//最高分
        double min=scores[0];//最低分
        for (int i=0;i< scores.length;i++){
            if (scores[i]>max){
                max = scores[i];
            }
            if (scores[i]<min){
                min = scores[i];
            }
        total+=scores[i];
        }
        System.out.println("最大平均分是:"+max);
        System.out.println("最小平均分是:"+min);
        double avg=(total-min-max)/(scores.length-2);//平均分
        return avg;
    }
}
